package com.lius.SpringBootStart.mapper;

import com.lius.SpringBootStart.domain.User;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

@Repository
public class UserMapper {

    private static Map<String, User> userMap = new HashMap<>();

    static {
        userMap.put("admin",new User(1,"超级管理员","admin","admin123456"));
        userMap.put("songj",new User(1,"宋江","songj","Songj123456"));
        userMap.put("linc",new User(2,"林冲","linc","Linc123456"));
        userMap.put("wuy",new User(3,"吴用","wuy","Wuy123456"));
    }

    public User login(String account, String passwd){
        User user = userMap.get(account);
        if(user != null && user.getPasswd().equals(passwd)){
                return user;
        }
        return null;
    }
}
